<?php


$this->set('album_usermenu', 'album_usermenu');
function album_usermenu()
{
	$obj =& get_instance();

 $menu = array(
	__("My albums", "album") => site_url("album/user/" . $obj->user->username),
	__("Sign out", "album") => site_url("member/logout")
	);
	
	return $menu;
}

$this->set('album_menu', 'album_menu');
function album_menu()
{
 $menu = array(
	__("Create an album", "album") => site_url("album/ampidiro"),
	__("Album list", "album") => site_url("album"),
	__("Tags", "album") => site_url("album/tag"),
	);
	
	return $menu;
}


$this->set('album_new_comments', 'album_new_comments');
function album_new_comments($params = array())
{
	$default_params = array
	(
		'limit' => 10
	);
	foreach ($default_params as $key => $value)
	{
		$params[$key] = (isset($params[$key]))? $params[$key]: $default_params[$key];
	}
	$params['order_by'] = 'id DESC';
	$obj =& get_instance();
	$obj->load->model('album_model', 'album');
	return $obj->album->get_comments($params);
	
}

$this->set('album_new_images', 'album_new_images');
function album_new_images($params = array())
{
	$default_params = array
	(
		'limit' => 10
	);
	
	foreach ($default_params as $key => $value)
	{
		$params[$key] = (isset($params[$key]))? $params[$key]: $default_params[$key];
	}
	$obj =& get_instance();
	$params['where'] = "g_id = '0'" ;
	$obj->load->model('album_model', 'album');
	$rows = $obj->album->get_images($params) ;
	return $rows;

}


$this->set('album_new_albums', 'album_new_albums');
function album_new_albums($params = array())
{
	$default_params = array
	(
		'limit' => 10
	);
	
	foreach ($default_params as $key => $value)
	{
		$params[$key] = (isset($params[$key]))? $params[$key]: $default_params[$key];
	}
	$obj =& get_instance();
	$obj->load->model('album_model', 'album');
	$rows = $obj->album->get_albums($params) ;
	return $rows;

}

$this->set('album_tags', 'album_tags');

function album_tags()
{
	$obj =& get_instance();
	$obj->load->model('album_model', 'album');
	return $obj->album->get_tags(array('order_by' => 'cnt DESC', 'limit' => 20));
}

$this->set('album_users', 'album_users');
function album_users()
{
	$obj =& get_instance();
	$obj->load->model('album_model', 'album');
	return $obj->album->get_users(array('order_by' => 'cnt DESC', 'limit' => 10));
}


$this->set('album_get_images', 'album_get_images');
function album_get_images($params = array())
{
	$default_params = array
	(
		'limit' => 10
	);
	
	$obj =& get_instance();
	$obj->load->model('album_model', 'album');
	if (isset($params['where']['album']))
	{
		$album = $obj->album->get_album(array('where' => array('a.title' => $params['where']['album'])));

		unset($params['where']['album']);
		$params['where']['album_images.aid'] = $album['aid'];
	}
	$rows = $obj->album->get_images($params) ;
	return $rows;

}
